$(function() {	
	$('#huodg11').datagrid({
		//请求地址
	    url:'../card/getCheckWithCard',
	    columns:[[
	    	{field:'',title:'',checkbox:true},
			{field:'withcardId',title:'配卡编号',width:'8%'},
			{field:'empId',title:'员工编号', width:'8%',
				formatter: function(value,row,index){
					if (row.emp){
						return row.emp.empId;
					} else {
						return "";
					}
				}},
			{field:'empName',title:'员工名称', width:'8%',
				formatter: function(value,row,index){
					if (row.emp){
						return row.emp.empName;
					} else {
						return "";
					}
				}},
			{field:'accountId',title:'考勤账套编号', width:'8%',
				formatter: function(value,row,index){
					if (row.checkAccount){
						return row.checkAccount.accountId;
					} else {
						return "";
					}
				}},
			{field:'effectivaDate',title:'生效时间',width:'8%'},
			{field:'expiryDate',title:'失效时间',width:'15%'},
			{field:'maker',title:'创建者',width:'8%'},
			{field:'makeTime',title:'创建日期',width:'15%'},
			{field:'updateEmp',title:'修改者',width:'8%'},
			{field:'updateTime',title:'修改日期',width:'15%'},
			{field:'state',title:'状态',width:'11%',
				formatter : function(value, row, index) {
					if (row.state === 'true') {
						var btn5 = " <input type='checkbox' checked=true>";
						return btn5;
					} else if (row.state === 'false') {
						var btn6 = " <input type='checkbox'>";
						return btn6;
					}
				}
			} ] ],
		onLoadError:function(data){
			alert("加载失败")
		},
	    width:'100%',
	    fit:true,
	    //fit:true
	    fitColumns:true,
	    //隔行变色
	    striped:true,
	    nowrap:true,
	    //显示行号
	    rownumbers:true,
	    //设置单选
	    singleSelect:true,
		toolbar:'#huotb11',
		//显示分页栏
		pagination:true,
		//设置每页大小
		pageSize:5,
		//可选的每页大小
		pageList:[5,10,20,50]
	});
});
 function searchname(value){
	 $('#huodg11').datagrid('load','../card/serchCheckWithCard?value='+value);
} 
	function removeit(){
			var rows = $('#huodg11').datagrid('getSelections');
			if(rows.withcardId!=null&&rows.withcardId!=""){
				$.messager.confirm('请确认','您确定要删除当前所有选中的项目吗？',function(r){
					if(r){
						var withcards = [];
						for(var i = 0; i < rows.length; i++){
							withcards.push(rows[i].withcardId)
						}
						var huo_rowData = JSON.stringify(withcards);
						alert(huo_rowData);
						$.ajax({
							url : "../card/deleteCheckWithCard",
							data : {"huo_rowData" : huo_rowData},
							success : function(e) {
								if (e == "ok") {
	                               alert("删除成功");
	                               $('#huodg11').datagrid('load');
								}
							}
						});
					}
				 })
			}else{
				alert("未选中数据")
			}
	}